package com.learn.threadpool;

import com.learn.constant.MathConstant;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * NewSingleThreadExecutor
 *
 * 创建一个单线程化的线程池，它只会用唯一的工作线程来执行任务，保证所有任务按照指定顺序(FIFO, LIFO, 优先级)执行
 */
public class NewSingleThreadExecutorTest {

    public static void main(String[] args) {

        int a = MathConstant.INT_ZERO;

        ExecutorService service = Executors.newSingleThreadExecutor();

        service.execute(new MyThread(a++));
        service.execute(new MyThread(a++));
        service.execute(new MyThread(a++));

    }

}
